:root {
    --primary-color: #4A90E2;
    --border-color: #E5E5E5;
    --bg-color: #F5F5F5;
    --grid-color: rgba(0, 0, 0, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-color);
}

.editor {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 顶部导航 */
.editor-header {
    height: 60px;
    background: white;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

.logo {
    font-weight: bold;
    font-size: 18px;
}

.actions {
    display: flex;
    gap: 10px;
}

.action-btn {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: white;
    cursor: pointer;
}

/* 主编辑区域 */
.editor-main {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 20px;
    padding: 20px;
    background: var(--bg-color);
    height: calc(100vh - 140px); /* 减去头部和底部的高度 */
    overflow: hidden;
}

/* 组件面板样式 */
.components-panel {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow-y: auto;
}

.panel-header {
    padding: 16px;
    font-weight: 500;
    border-bottom: 1px solid var(--border-color);
}

.components-list {
    padding: 16px;
}

.component-group {
    margin-bottom: 24px;
}

.group-title {
    font-size: 13px;
    color: #666;
    margin-bottom: 12px;
}

.component-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.component-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px 8px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: move;
    transition: all 0.2s;
}

.component-item:hover {
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.component-item span {
    font-size: 12px;
    color: #666;
}

/* 组件图标样式优化 */
.item-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: color 0.2s;
}

.component-item:hover .item-icon {
    color: var(--primary-color);
}

.item-icon svg {
    width: 24px;
    height: 24px;
}

/* 画布容器改进 */
.canvas-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.canvas {
    flex: 1;
    overflow-y: auto;
    position: relative;
    padding: 20px;
}

.editable-area {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    min-height: 100%;
    background: white;
    position: relative;
}

/* 预览模式样式 */
.preview-mode .editable-area {
    padding: 0;
}

.preview-mode .component-controls {
    display: none;
}

/* 组件占位符样式 */
.component-placeholder {
    border: 2px dashed var(--border-color);
    padding: 20px;
    margin: 10px 0;
    background: rgba(74, 144, 226, 0.05);
    text-align: center;
    cursor: pointer;
}

.component-placeholder:hover {
    border-color: var(--primary-color);
    background: rgba(74, 144, 226, 0.1);
}

/* 网格背景改进 */
.grid-lines {
    background-image:
            linear-gradient(var(--grid-color) 1px, transparent 1px),
            linear-gradient(90deg, var(--grid-color) 1px, transparent 1px),
            linear-gradient(var(--grid-color) .5px, transparent .5px),
            linear-gradient(90deg, var(--grid-color) .5px, transparent .5px);
    background-size: 50px 50px, 50px 50px, 10px 10px, 10px 10px;
}

/* 修改可编辑组件样式，确保不影响原有样式 */
.editable-component {
    position: relative;
    margin: 2px 0;
    min-height: 20px;
}

/* 添加一个伪元素来显示虚线边框，这样不会影响原始内容 */
.editable-component::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 1px dashed transparent;
    pointer-events: none;
    z-index: 1;
}

.editable-component:hover::before {
    border-color: var(--primary-color);
}

.editable-component.selected::before {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(24,144,255,0.1);
}

/* 确保内容不受编辑框影响 */
.element-content {
    position: relative;
    z-index: 0;
}

/* 控制按钮始终显示在最上层 */
.component-controls {
    position: absolute;
    top: -24px;
    right: 0;
    display: none;
    background: var(--primary-color);
    border-radius: 4px 4px 0 0;
    overflow: hidden;
    z-index: 2;
}

.editable-component:hover .component-controls {
    display: flex;
}

/* 拖放指示器样式优化 */
.drop-before::before {
    border-top: 2px solid var(--primary-color) !important;
}

.drop-after::before {
    border-bottom: 2px solid var(--primary-color) !important;
}

/* 样式编辑器 */
.style-editor {
    position: fixed;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    width: 300px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
}

.style-editor-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.style-editor-content {
    padding: 16px;
    max-height: 60vh;
    overflow-y: auto;
}

.style-item {
    margin-bottom: 12px;
}

.style-item label {
    display: block;
    margin-bottom: 4px;
    color: #666;
    font-size: 12px;
}

.style-item input,
.style-item select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.style-item input[type="color"] {
    padding: 2px;
    height: 32px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #999;
}

.close-btn:hover {
    color: #666;
}

.control-btn {
    padding: 2px 6px;
    background: none;
    border: none;
    color: white;
    font-size: 12px;
    cursor: pointer;
}

.control-btn:hover {
    background: rgba(255,255,255,0.2);
}

.delete-btn {
    padding: 2px 6px;
    font-size: 12px;
}

.canvas-header {
    text-align: center;
    padding: 40px 20px;
}

.canvas-header h2 {
    font-size: 32px;
    margin-bottom: 16px;
}

.subtitle {
    color: #666;
    font-size: 16px;
}

/* 拖放区域样式 */
.drop-zone {
    border: 2px dashed var(--border-color);
    margin: 10px 0;
    padding: 20px;
    background: rgba(74, 144, 226, 0.05);
    text-align: center;
    color: #666;
}

.drop-zone.active {
    border-color: var(--primary-color);
    background: rgba(74, 144, 226, 0.1);
}

/* 底部操作栏 */
.editor-footer {
    height: 80px;
    background: white;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 0 20px;
}

.primary-btn {
    padding: 12px 32px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
}

.secondary-btn {
    padding: 12px 32px;
    background: white;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
}

/* 组件样式 */
.section {
    position: relative;
    margin: 10px 0;
    padding: 20px;
    border: 1px dashed var(--border-color);
    min-height: 100px;
}

.section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 1px solid transparent;
    pointer-events: none;
}

.section:hover::before {
    border-color: var(--primary-color);
}

/* 图片上传相关样式 */
.image-placeholder {
    position: relative;
    min-height: 100px;
    border: 2px dashed var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 20px;
    cursor: pointer;
}

.image-placeholder:hover {
    border-color: var(--primary-color);
    background: rgba(24,144,255,0.05);
}

.upload-text {
    margin-top: 10px;
    color: #666;
    font-size: 14px;
}

/* 添加拖放相关样式 */
.editable-component.drop-before {
    border-top: 2px solid var(--primary-color);
}

.editable-component.drop-after {
    border-bottom: 2px solid var(--primary-color);
}

/* 编辑提示样式 */
.editing-hints {
    padding: 20px;
    margin-bottom: 20px;
    background: rgba(24,144,255,0.05);
    border-radius: 8px;
}

.hint {
    display: flex;
    gap: 20px;
    justify-content: center;
    color: #666;
}

.hint span {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 确保拖放区域可见 */
.editable-area {
    min-height: 200px;
    padding: 20px;
    background: white;
    border-radius: 8px;
}

/* 拖放时的视觉反馈 */
.editable-area.drag-over {
    background: rgba(24,144,255,0.05);
    border: 2px dashed var(--primary-color);
}

.custom-button {
    display: inline-block;  /* 允许宽度由内容决定 */
    width: auto;           /* 避免固定宽度 */
}

/* 顶部发送按钮样式调整 */
.actions .primary {
    background: #4f46e5 !important; /* 主色与第二个页面一致 */
    color: white !important;
    border: none !important;
    display: flex;
    align-items: center;
    gap: 8px; /* 图标文字间距 */
    padding: 8px 16px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.actions .primary svg {
    width: 20px; /* 与第二个页面图标尺寸一致 */
    height: 20px;
    stroke-width: 1.8; /* 线条粗细调整 */
    margin-right: 0; /* 移除原有间距 */
}

.actions .primary:hover {
    background: #4338ca !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 统一发送邮件弹窗样式 */
#send-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 2000;
}

.send-modal-content {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 2rem;
    width: 90%;
    max-width: 500px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.send-modal-content h2 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    color: #1f2937;
}

.close {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 1.5rem;
    color: #6b7280;
    cursor: pointer;
    transition: color 0.2s;
}

.close:hover {
    color: #1f2937;
}

/* 统一表单样式 */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #1f2937;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    transition: all 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* 统一按钮样式 */
.button {
    display: inline-flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.button-primary {
    background: #4f46e5;
    color: white;
    border: none;
}

.button-primary:hover {
    background: #4338ca;
}

.button-secondary {
    background: white;
    color: #4f46e5;
    border: 1px solid #e5e7eb;
}

.button-secondary:hover {
    background: #f3f4f6;
}

/* 文件上传样式 */
.file-upload {
    position: relative;
    margin-top: 0.5rem;
}

.custom-file-input {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.9);
    border: 2px dashed #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.custom-file-input:hover {
    border-color: #4f46e5;
    background: rgba(79, 70, 229, 0.05);
}

/* 加载动画 */
.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 附件上传提示 */
.hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: var(--light-text-color);
}

/* 文件输入美化 */
input[type="file"] {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: rgba(255,255,255,0.9);
}
/* 文件上传容器 */
.file-upload {
    position: relative;
    width: 100%;
}

/* 隐藏原生input */
.file-upload input[type="file"] {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

/* 自定义按钮样式 */
.custom-file-input {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    background: rgba(255,255,255,0.9);
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.custom-file-input:hover {
    background: rgba(79, 70, 229, 0.05);
    border-color: var(--primary-color);
}

.custom-file-input svg {
    width: 1.5rem;
    height: 1.5rem;
    color: var(--primary-color);
}

.custom-file-input span {
    color: var(--text-color);
    font-weight: 500;
}

/* 优化文件信息显示样式 */
.file-info {
    white-space: pre-wrap;
    background: #f8f9fa;
    border-radius: 4px;
    padding: 8px;
    margin-top: 8px;
    border: 1px dashed #dee2e6;
    max-height: 200px;
    overflow-y: auto;
    line-height: 1.5;
}

/* 拖拽状态 */
.file-upload.dragover .custom-file-input {
    background: rgba(79, 70, 229, 0.1);
    border-color: var(--primary-color);
}